#ifndef CLOUD_MSG_H
#define CLOUD_MSG_H
#include <rtthread.h>

#define EMU_SN "1234567"
//topic
#define emu_wnParam_upload_topic        "Param/Emu/%s/TimedUpload"  //emu 参数定时上传
#define emu_emeterParam_upload_topic    "Param/%s/TimedUpload/meterData" //电表上传数据
#define cloud_setEmuTime_topic          "SetTime/Emu/%s/TimeZone"   //云端->设置Emu时区
#define emu_resp_setEmuTime_topic       "SetTime/Emu/%s/TimeZone/Reponse" //enum回复
#define cloud_readInv_topic             "ReadParam/Emu/%s/Inv"  //云端->读取Inv数据
#define emu_resp_readInv_topic          "ReadParam/Emu/%s/Inv/Response" //emu->云端  回复
#define cloud_readEmu_topic             "ReadParam/%s/Emu"  //云端->emu 读取emu参数
#define emu_resp_readEmu_topic          "ReadParam/%s/Emu/Response" //emu->云端  回复
#define cloud_readAll_topic             "ReadParam/%s/All" //云端->emu 读取全部数据
#define emu_resp_readAll_topic          "ReadParam/%s/All/Response"
#define cloud_writeInv_topic            "WriteParam/Emu/%s/Inv"
#define emu_resp_writeInv_topic         "WriteParam/Emu/%s/Inv/Response"
#define cloud_writeEmu_topic            "WriteParam/Emu/%s/Emu"
#define emu_resp_writeEmu_topic         "WriteParam/Emu/%s/Emu/Response"
#define cloud_readEnergyFile_topic      "ReadFile/Emu/%s/Energy"
#define emu_resp_EnergyFile_topic       "ReadFile/Emu/%s/Energy/Reponse"
#define cloud_readFaultLog_topic        "ReadFile/Emu/%s/FaultLog"
#define emu_resp_FaultLog_topic         "ReadFile/Emu/%s/ReponseFaultLog"

#define cloud_upgrade_topic             "Upgrade/Emu/%s/UpgradeFile"
#define emu_resp_upgrade_topic          "Upgrade/Emu/%s/UpgradeFile/Reponse"
#define cloud_netSetting_topic          "Comm/Emu/%s/Config"
#define emu_resp_netSetting_topic       "Comm/Emu/%s/ReponseConfigResult"
#define cloud_updatePwd_topic           "Comm/Emu/%s/updatePwd"
#define emu_resp_updatePwd_topic        "Comm/Emu/%s/updatePwd/Reponse"
enum{
    METHOD_UPLOAD, //emu 主动上传
    METHOD_REQ,     //cloud 请求
    METHOD_REP      //emu 回复
};

#define REQURL_NULL     ""
#define RESPURL_NULL    ""


typedef int(*msg_uploadhandle)(uint8_t *outdata);
typedef int(*msg_reqhandle)(uint8_t *querydata,uint8_t *outdata);
typedef struct {
    uint8_t name[32];
    uint8_t requrl[64];
    uint8_t respurl[64];
    uint32_t method;       //0:get, 1:put
    msg_reqhandle req_handle;
    msg_uploadhandle upload_handle;

}msg_dealfuns;

msg_dealfuns* msg_getfun_node(const char* name,const char* url);
int emu_wnParam_upload(rt_uint8_t*outdata);
//int emu_wnParam_upload(uint8_t*outdata);

int emu_readInv(uint8_t *querydata,uint8_t *outdata);
int emu_setTime(uint8_t *querydata,uint8_t *outdata);
int emu_readEmu(uint8_t *querydata,uint8_t *outdata);
int emu_readAll(uint8_t *querydata,uint8_t *outdata);
int emu_writeInv(uint8_t *querydata,uint8_t *outdata);
int emu_writeEmu(uint8_t *querydata,uint8_t* outdata);


int emu_upgrade(uint8_t *querydata,uint8_t* outdata);
int emu_netSetting(uint8_t *querydata,uint8_t* outdata);
int emu_updatePwd(uint8_t *querydata,uint8_t* outdata);
#endif
